<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Agenda</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">

    <!-- Le styles -->
    <link href="../assets/css/bootstrap.css" rel="stylesheet">
    <style type="text/css">
      body {
        padding-top: 60px;
        padding-bottom: 40px;
      }
    </style>
    <link href="http://localhost:8000/static/bootstrap.css" rel="stylesheet">

    <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
      <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->

    <!-- Le fav and touch icons -->
    <link rel="shortcut icon" href="../assets/ico/favicon.ico">
    <link rel="apple-touch-icon-precomposed" sizes="144x144" href="../assets/ico/apple-touch-icon-144-precomposed.png">
    <link rel="apple-touch-icon-precomposed" sizes="114x114" href="../assets/ico/apple-touch-icon-114-precomposed.png">
    <link rel="apple-touch-icon-precomposed" sizes="72x72" href="../assets/ico/apple-touch-icon-72-precomposed.png">
    <link rel="apple-touch-icon-precomposed" href="../assets/ico/apple-touch-icon-57-precomposed.png">


		<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
		<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.js"></script>
		
		<script type="text/javascript">
			$(document).ready(function(){
			$('#agenda').validate();
			$('#ActivityForm').validate();
			$('#EditForm').validate();
			
			});
		    $().ready(function() 
		    {
		    $.validator.addMethod("time", function(value, element) 
		    {  
		    return this.optional(element) || /^(([0-1]?[0-9])|([2][0-3])):([0-5]?[0-9])(:([0-5]?[0-9]))?$/i.test(value);  
		    }, "Please enter a valid time format HH:MM.");
		
		        $("#input").validate({
		                rules: {
		                        time: "required time",
		                },
		
		        });
				$("#EditForm").validate({
		                rules: {
		                        time: "required time",
		                },
		
		        });
		    });
		
		</script>
		<script type="text/javascript">
			var counter = 0
			function checkSelected(id) 
			{
					counter=1;
					$('#edit').hide();
					$('#addFields').hide();
				    $('#editFields').show(1000);
					
			}
			
			function check() 
			{
					var r = confirm ("Are you sure you want to delete the activity ?")
					if (r == false)
					{
						return false;
					}
					else 
					{
						EditForm.action = '/deleteActivity/';
					}
					
			}
			
			function save(){
			if(counter == 0) 
			{
					$('#edit').show();
					$('#delete').hide();
					
					return false;
				}
				else{
				 return true;
				}
			
			}
			
			
			function done(){
				$('#editFields').hide(1000);							
				$('#addFields').show();
			
			}
</script>

  </head>

  <body>

    <div class="navbar navbar-fixed-top">
      <div class="navbar-inner">
        <div class="container">
          <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </a>
          <a class="brand" href="#">Eventati</a>
          <div class="nav-collapse">
            <ul class="nav">
              <li class="active"><a href="#">Home</a></li>
              <li><a href="#about">About</a></li>
              <li><a href="#contact">Contact</a></li>
            </ul>
          </div><!--/.nav-collapse -->
        </div>
      </div>
    </div>

    <div class="container">
		<h1>Event's Agenda</h1>
      <!-- Main hero unit for a primary marketing message or call to action -->
      <div class="hero-unit">
{% if not creation %}
	
<div id = "agendaform">
	<form name="AgendaCreationForm" id="agenda" action="/createAnAgenda/" method="POST">
	Agenda's Title :<input type="text" size="20" name="title" value="{{agenda.title}}"  class = "required" />
	<INPUT type="submit" id = "agenda" value="Add Agenda"/>
	
	</form>
	</div>

{% endif %}

{% if creation %}
	{% if Activities %}

		<form id = "EditForm" name="EditForm" action="/editActivity/"  method="POST"> 
<TABLE id="Agenda" width="500px" border="1" align="center">
<thead>
        <tr>
        	<th></th>
            <th> Edit </th>           
   			<th> Time</th>
   			<th> Description</th>
  		</tr>
</thead>
<tfoot>
  		{% for A in Activities %}
			  <tr>
			  <TD> <input type="image" name="delete" , value = "{{ A.id }}" src="http://icons.iconarchive.com/icons/deleket/sleek-xp-basic/16/Close-2-icon.png" onclick = "return check();"></TD>
			  <TD><INPUT type="radio" name="activity" , value = "{{ A.id }}" onclick = "checkSelected('{{ A.id }}')">
			  <TD> <OUTPUT type = "time" name = "time" /> {{ A.startTime }} - {{  A.endTime }} </TD>
			  <TD>  <OUTPUT type = "text" /> {{ A.description }} </TD>
			  </tr>
		 {% endfor %}
</tfoor>
      </TABLE>
      
          <div id="editFields" style="display:none;"><h3> Edit activity :</h3> 
        Description : <input  id = "textID" type="text" size="20" name="textID" value="{{text}}"  class = "required" /></br>
  		Start Time  : <input id="startID" size="20" align="left" type="time" name = "startID"  value="{{start}}" class = "required" /></br>
  		End Time    : <input id="endID" size="20" align="right" type="time"  name = "endID"   value="{{end}}" class = "required" />
    
 	  <div id="edit" style="display:none;"> <font face="Comic Sans MS" color="red"> You haven't checked any activity to be edited </font></div>
 	  <INPUT type="image"  name = "edit" src="http://icons.iconarchive.com/icons/jackietran/rounded/24/Done-icon.png " onclick = "return save();"/><br />
 	  
 	  <INPUT type="button"  name = "edit" value="Done Editing" onclick = "return done();"/><br />
 	  
 	   </div>
 	   
 	  		{%if wrongEditTime%}
 	  		<script>
 	  		editCheck() 
 	  		</script>
			<p> <font color = "RED">Kindly enter valid times that match the event's timings</font></p>
		{% endif %}
		
		
 	  </form>
 	  
          <div id="addFields" ><h3>

    <h3> Add an activity :</h3> 
   		
<form name="ActivityForm" id="input"  action="/createActivity/" method="POST">
  Description : <input  id = "textID" type="text" size="20" name="textID"   class = "required" /></br>
  Start Time  : <input id="startID" size="20" align="left" type="time" name = "startID"   class = "required" /></br>
  End Time    : <input id="endID" size="20" align="right" type="time"  name = "endID"   class = "required" />
 
  <INPUT type="submit" value="Add Activity"  />  
  </div>
  </form>

		{%if wrongTime%}
		 	  		<script>
 	  		editCheck() 
 	  		</script>
			<p> <font color = "RED">Kindly enter valid times that match the event's timings</font></p>
		{% endif %}

		{% else %}

	 	  <div id="Empty"> <font color="red"><h3> You haven't added any activities to your Agenda </font></h3></div>
	 	          <div id="addFields" >

    <h3> Add an activity :</h3> 
   		
<form name="ActivityForm" id="input"  action="/createActivity/" method="POST">
  Description : <input  id = "textID" type="text" size="20" name="textID"   class = "required" /></br>
  Start Time  : <input id="startID" size="20" align="left" type="time" name = "startID"   class = "required" /></br>
  End Time    : <input id="endID" size="20" align="right" type="time"  name = "endID"   class = "required" />
 
  <INPUT type="submit" value="Add Activity"  />  
  </div>
  </form>
	{% endif %}
		
			<form action="/media/" method="POST">
		{% csrf_token %}
		<input type="submit" name="name" value="next" /></form>
{% endif %}	
      </div>

      
      </div>

      <hr>

      <footer>
   <div class="navbar navbar-fixed-top">
      <div class="navbar-inner">
        <div class="container">
          <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </a>
          <div class="nav-collapse">
            <ul class="nav">
          <a class="brand" href="/homePage/">Eventati</a>
              <li > <a href="/AboutUs/">About Us</a></li>
              <li><a href="/ViewInstructions/">Instructions</a></li>
              <li><a href  ="/Terms&Conditions/">  Terms & Conditions</a></li>
         <li><a href  ="/News/">  Latest News and Updates</a></li>
         <li><a href ="/Faqs/"> FAQS</a></li>
         <li><a href ="/Contactus/"> Contactus</a></li>
                       <li><a href="/logout/" method="POST">Log out</a></li>
         
         
              
            </ul>
          </div><!--/.nav-collapse -->
        </div>
      </div>
    </div>
         				<p class="pull-right"><a href="#">Back to top</a></p>
				        <p>&copy; Company 2012</p>      </footer>

    </div> <!-- /container -->

    <!-- Le javascript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="../assets/js/jquery.js"></script>
    <script src="../assets/js/bootstrap-transition.js"></script>
    <script src="../assets/js/bootstrap-alert.js"></script>
    <script src="../assets/js/bootstrap-modal.js"></script>
    <script src="../assets/js/bootstrap-dropdown.js"></script>
    <script src="../assets/js/bootstrap-scrollspy.js"></script>
    <script src="../assets/js/bootstrap-tab.js"></script>
    <script src="../assets/js/bootstrap-tooltip.js"></script>
    <script src="../assets/js/bootstrap-popover.js"></script>
    <script src="../assets/js/bootstrap-button.js"></script>
    <script src="../assets/js/bootstrap-collapse.js"></script>
    <script src="../assets/js/bootstrap-carousel.js"></script>
    <script src="../assets/js/bootstrap-typeahead.js"></script>

  </body>
</html>
